import { getToken, setToken, removeToken } from '@/utils/auth'
// import axios from 'axios'
// import service from '@/utils/request'
import { loginApi } from '@/api/user'
export default {
  state() {
    return {
      token: getToken()
    }
  },
  mutations: {
    setTokenMutations(state, token) {
      state.token = token
      setToken(token)
    },
    removeTokenMutations(state, token) {
      removeToken()
    }
  },
  actions: {
    async  loginAction({ commit }, data) {
      const res = await loginApi(data)
      console.log(res)
      commit('setTokenMutations', res.data)
    }
  },
  getters: {},
  namespaced: true
}
